﻿//-----------------------------------------------------------------------
// <copyright file="ProjectsWithCommandFilter.cs" author="Artak Mkrtchyan">
//     Creative Commons - GNU General Public License (http://creativecommons.org/licenses/GPL/2.0/
// </copyright>
// <author>Artak Mkrtchyan</author>
// <email>mkArtak@gmail.com</email>
// <date>02/06/2013</date>
//-----------------------------------------------------------------------

using ConsoleHoster.Common.Model;
using ConsoleHoster.Common.Utilities;
using ConsoleHoster.Common.Utilities.Threading;
using ConsoleHoster.Model.Entities;
using ConsoleHoster.View.Popups;
using System.Collections.Generic;

namespace ConsoleHoster.ViewModel
{
	internal class ProjectsWithCommandFilter : GenericSettingsProvider<ProjectsAndCommandsSelector, IEnumerable<ConsoleProject>, IEnumerable<ConsoleProject>>, IProjectsFilter
	{
		public ProjectsWithCommandFilter(IDispatcher argDispatcher, ILogger argLogger, ViewSettings argViewSettings)
			: base(argDispatcher, argViewSettings, new ComponentLogger("ProjectsWithCommandFilter", argLogger))
		{
		}

		protected override ProjectsAndCommandsSelector CreateView(IEnumerable<ConsoleProject> argCurrentState)
		{
			return new ProjectsAndCommandsSelector
			{
				DataContext = new ProjectsAndCommandsSelectorViewModel(this.Mode, argCurrentState, this.Dispatcher, this.Logger)
			};
		}

		protected override IEnumerable<ConsoleProject> RetrieveDataFromView()
		{
			return this.view.ViewModel.GetFilteredProjectsList();
		}

		public ProjectsFilterMode Mode
		{
			get;
			set;
		}
	}
}
